package org.runtimedao.compiler;

import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;

public class AppFileManager extends ForwardingJavaFileManager<JavaFileManager> {

	private AppClassLoader classLoader;
	private AppJavaFileObject sourceObj;
	private AppJavaFileObject compiledObj;

	public AppFileManager(JavaFileManager fileManager,
			AppClassLoader classLoader) {
		super(fileManager);
		this.classLoader = classLoader;
	}

	public void setObjects(AppJavaFileObject sourceObj,
			AppJavaFileObject compiledObj) {
		this.sourceObj = sourceObj;
		this.compiledObj = compiledObj;
		classLoader.setCompiledObj(compiledObj);
	}

	public FileObject getFileForInput(Location location, String packageName,
			String relativeName) {
		return sourceObj;
	}

	public JavaFileObject getJavaFileForOutput(Location location,
			String qualifiedName, Kind kind, FileObject outputFile) {
		return compiledObj;
	}

	public ClassLoader getClassLoader(Location location) {
		return classLoader;
	}
}
